
package com.akupilih.app;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.MenuItem;

import com.akupilih.app.adapter.VoteAdapter;
import com.akupilih.app.helper.PagerSlidingTabStrip;

public class VoteHasilActivity extends BaseActivity {
    private ViewPager viewPage;
    private PagerSlidingTabStrip tabs;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_hasil_vote);
        tabs = (PagerSlidingTabStrip) findViewById(R.id.v_tabs);
        getSupportActionBar().setTitle("Vote");
        viewPage = (ViewPager) findViewById(R.id.v_viewpager);
        /** Defining a listener for pageChange */
        ViewPager.SimpleOnPageChangeListener pageChangeListener = new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
                super.onPageSelected(position);
                viewPage = (ViewPager) findViewById(R.id.v_viewpager);
            }
        };
        VoteAdapter adapter = new VoteAdapter(this.getSupportFragmentManager());
        viewPage.setAdapter(adapter);
        viewPage.setCurrentItem(0);
        viewPage.setOnPageChangeListener(pageChangeListener);
        tabs.setViewPager(viewPage);
        tabs.setOnPageChangeListener(pageChangeListener);
        tabs.setIndicatorColor(Color.parseColor("#CC0000"));
        tabs.setIndicatorHeight(3);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // TODO Auto-generated method stub
        if (item.getItemId() == android.R.id.home) {
            finish();
        }
        return true;
    }

}
